package ldkxingzhe.ldkxingzhedemo.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

/**
 * Created by liangdengke on 2015/8/17.
 */
public class StartServiceService extends Service{
    @Override
    public IBinder onBind(Intent intent) {
        Log.d("TAG","onBind");
        printThread();
        return binder;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        printThread();
        Log.d("TAG","onStartCommand");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        printThread();
        Log.d("TAG","onCreate");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        printThread();
        Log.d("TAG","onDestroy");
    }

    private void printThread(){
        Log.d("TAG","Thread = " + Thread.currentThread());
    }

    public class MyBinder extends Binder{
        StartServiceService getService(){
            return StartServiceService.this;
        }
    }
    private MyBinder binder = new MyBinder();
}
